package org.jcodec.codecs.mpeg4;

import org.jcodec.codecs.mpeg4.Macroblock.Vector;

/**
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author The JCodec project
 * 
 */
public class MPEG4Consts {
    static final Vector ZERO_MV = Macroblock.vec();
    
    static final int BS_VERSION_BUGGY_DC_CLIP = 34;
    static final int MODE_INTER = 0;
    static final int MODE_INTER_Q = 1;
    static final int MODE_INTER4V = 2;
    static final int MODE_INTRA = 3;
    static final int MODE_INTRA_Q = 4;
    static final int MODE_NOT_CODED = 16;
    static final int MODE_NOT_CODED_GMC = 17;
    static final int MODE_DIRECT = 0;
    static final int MODE_INTERPOLATE = 1;
    static final int MODE_BACKWARD = 2;
    static final int MODE_FORWARD = 3;
    static final int MODE_DIRECT_NONE_MV = 4;
    static final int MODE_DIRECT_NO4V = 5;
    static final int[] ROUNDTAB_76 = { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 };
    static final int[] ROUNDTAB_79 = { 0, 1, 0, 0 };
    static final int ALT_CHROMA_ROUNDING = 1;

//@formatter:off
    static final int INTRA_DC_THRESHOLD_TABLE[] = { 32, 13, 15, 17, 19, 21, 23, 1 };
    static final short[] DEFAULT_INTRA_MATRIX = {
        8, 17, 18, 19, 21, 23, 25, 27,
        17, 18, 19, 21, 23, 25, 27, 28,
        20, 21, 22, 23, 24, 26, 28, 30,
        21, 22, 23, 24, 26, 28, 30, 32,
        22, 23, 24, 26, 28, 30, 32, 35,
        23, 24, 26, 28, 30, 32, 35, 38,
        25, 26, 28, 30, 32, 35, 38, 41,
        27, 28, 30, 32, 35, 38, 41, 45
    };

    static final short[] DEFAULT_INTER_MATRIX = {
        16, 17, 18, 19, 20, 21, 22, 23,
        17, 18, 19, 20, 21, 22, 23, 24,
        18, 19, 20, 21, 22, 23, 24, 25,
        19, 20, 21, 22, 23, 24, 26, 27,
        20, 21, 22, 23, 25, 26, 27, 28,
        21, 22, 23, 24, 26, 27, 28, 30,
        22, 23, 24, 26, 27, 28, 30, 31,
        23, 24, 25, 27, 28, 30, 31, 33
    };
    
    static final int[][] MCBPC_INTRA_TABLE = {
        {-1, 0}, {20, 6}, {36, 6}, {52, 6}, {4, 4},  {4, 4},  {4, 4},  {4, 4},
        {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3}, {19, 3},
        {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3}, {35, 3},
        {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3}, {51, 3},
        {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
        {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
        {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},
        {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1},  {3, 1}
    };
    
    static final int[][] MCBPC_INTER_TABLE = {
        {-1, 0}, {255, 9}, {52, 9}, {36, 9}, {20, 9}, {49, 9}, {35, 8}, {35, 8},
        {19, 8}, {19, 8}, {50, 8}, {50, 8}, {51, 7}, {51, 7}, {51, 7}, {51, 7},
        {34, 7}, {34, 7}, {34, 7}, {34, 7}, {18, 7}, {18, 7}, {18, 7}, {18, 7},
        {33, 7}, {33, 7}, {33, 7}, {33, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
        {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6}, {4, 6},
        {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6}, {48, 6},
        {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5},
        {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5}, {3, 5},
        {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
        {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
        {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
        {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4}, {32, 4},
        {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
        {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
        {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
        {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4}, {16, 4},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3}, {2, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3}, {1, 3},
        {0, 1}
    };
    
    static final int CBPY_TABLE[][] = {
        {-1, 0}, {-1, 0}, {6, 6},  {9, 6},  {8, 5},  {8, 5},  {4, 5},  {4, 5},
        {2, 5},  {2, 5},  {1, 5},  {1, 5},  {0, 4},  {0, 4},  {0, 4},  {0, 4},
        {12, 4}, {12, 4}, {12, 4}, {12, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
        {14, 4}, {14, 4}, {14, 4}, {14, 4}, {5, 4},  {5, 4},  {5, 4},  {5, 4},
        {13, 4}, {13, 4}, {13, 4}, {13, 4}, {3, 4},  {3, 4},  {3, 4},  {3, 4},
        {11, 4}, {11, 4}, {11, 4}, {11, 4}, {7, 4},  {7, 4},  {7, 4},  {7, 4},
        {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2},
        {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}, {15, 2}
    };
    
    static final int[][] TMNMV_TAB_0 = {
        {3, 4}, {-3, 4}, {2, 3}, {2, 3}, {-2, 3}, {-2, 3}, {1, 2},
        {1, 2}, {1, 2}, {1, 2}, {-1, 2}, {-1, 2}, {-1, 2}, {-1, 2}
    };
    
    static final int[][] TMNMV_TAB_1 = {
        {12, 10}, {-12, 10}, { 11, 10}, {-11, 10},
        {10,  9}, { 10,  9}, {-10,  9}, {-10,  9},
        { 9,  9}, {  9,  9}, { -9,  9}, { -9,  9},
        { 8,  9}, {  8,  9}, { -8,  9}, { -8,  9},
        { 7,  7}, {  7,  7}, {  7,  7}, {  7,  7},
        { 7,  7}, {  7,  7}, {  7,  7}, {  7,  7},
        {-7,  7}, { -7,  7}, { -7,  7}, { -7,  7},
        {-7,  7}, { -7,  7}, { -7,  7}, { -7,  7},
        { 6,  7}, {  6,  7}, {  6,  7}, {  6,  7},
        { 6,  7}, {  6,  7}, {  6,  7}, {  6,  7},
        {-6,  7}, { -6,  7}, { -6,  7}, { -6,  7},
        {-6,  7}, { -6,  7}, { -6,  7}, { -6,  7},
        { 5,  7}, {  5,  7}, {  5,  7}, {  5,  7},
        { 5,  7}, {  5,  7}, {  5,  7}, {  5,  7},
        {-5,  7}, { -5,  7}, { -5,  7}, { -5,  7},
        {-5,  7}, { -5,  7}, { -5,  7}, { -5,  7},
        { 4,  6}, {  4,  6}, {  4,  6}, {  4,  6},
        { 4,  6}, {  4,  6}, {  4,  6}, {  4,  6},
        { 4,  6}, {  4,  6}, {  4,  6}, {  4,  6},
        { 4,  6}, {  4,  6}, {  4,  6}, {  4,  6},
        {-4,  6}, { -4,  6}, { -4,  6}, { -4,  6},
        {-4,  6}, { -4,  6}, { -4,  6}, { -4,  6},
        {-4,  6}, { -4,  6}, { -4,  6}, { -4,  6},
        {-4,  6}, { -4,  6}, { -4,  6}, { -4,  6}
    };
    
    static final int[][] TMNMV_TAB_2 = {
        {32, 12}, {-32, 12}, {31, 12}, {-31, 12},
        {30, 11}, {30, 11}, {-30, 11}, {-30, 11},
        {29, 11}, {29, 11}, {-29, 11}, {-29, 11},
        {28, 11}, {28, 11}, {-28, 11}, {-28, 11},
        {27, 11}, {27, 11}, {-27, 11}, {-27, 11},
        {26, 11}, {26, 11}, {-26, 11}, {-26, 11},
        {25, 11}, {25, 11}, {-25, 11}, {-25, 11},
        {24, 10}, {24, 10}, {24, 10}, {24, 10},
        {-24, 10}, {-24, 10}, {-24, 10}, {-24, 10},
        {23, 10}, {23, 10}, {23, 10}, {23, 10},
        {-23, 10}, {-23, 10}, {-23, 10}, {-23, 10},
        {22, 10}, {22, 10}, {22, 10}, {22, 10},
        {-22, 10}, {-22, 10}, {-22, 10}, {-22, 10},
        {21, 10}, {21, 10}, {21, 10}, {21, 10},
        {-21, 10}, {-21, 10}, {-21, 10}, {-21, 10},
        {20, 10}, {20, 10}, {20, 10}, {20, 10},
        {-20, 10}, {-20, 10}, {-20, 10}, {-20, 10},
        {19, 10}, {19, 10}, {19, 10}, {19, 10},
        {-19, 10}, {-19, 10}, {-19, 10}, {-19, 10},
        {18, 10}, {18, 10}, {18, 10}, {18, 10},
        {-18, 10}, {-18, 10}, {-18, 10}, {-18, 10},
        {17, 10}, {17, 10}, {17, 10}, {17, 10},
        {-17, 10}, {-17, 10}, {-17, 10}, {-17, 10},
        {16, 10}, {16, 10}, {16, 10}, {16, 10},
        {-16, 10}, {-16, 10}, {-16, 10}, {-16, 10},
        {15, 10}, {15, 10}, {15, 10}, {15, 10},
        {-15, 10}, {-15, 10}, {-15, 10}, {-15, 10},
        {14, 10}, {14, 10}, {14, 10}, {14, 10},
        {-14, 10}, {-14, 10}, {-14, 10}, {-14, 10},
        {13, 10}, {13, 10}, {13, 10}, {13, 10},
        {-13, 10}, {-13, 10}, {-13, 10}, {-13, 10}
    };

    static final byte MAX_LEVEL[][][] = {
        {
            /* intra = 0, last = 0 */
            {
                12, 6, 4, 3, 3, 3, 3, 2,
                2, 2, 2, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0
            },
            /* intra = 0, last = 1 */
            {
                3, 2, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0
            }
        },
        {
            /* intra = 1, last = 0 */
            {
                27, 10, 5, 4, 3, 3, 3, 3,
                2, 2, 1, 1, 1, 1, 1, 0,
                 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0
            },
            /* intra = 1, last = 1 */
            {
                8, 3, 2, 2, 2, 2, 2, 1,
                1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0
            }
        }
    };
    
    static final byte MAX_RUN[][][] = {
        {
            /* intra = 0, last = 0 */
            {
                0, 26, 10, 6, 2, 1, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
            },
            /* intra = 0, last = 1 */
            {
                0, 40, 1, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
            }
        },
        {
            /* intra = 1, last = 0 */
            {
                0, 14, 9, 7, 3, 2, 1, 1,
                1, 1, 1, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
            },
            /* intra = 1, last = 1 */
            {
                0, 20, 6, 1, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0,
            }
        }
    };
    static final int[][][] COEFF_TAB = {{
        /* intra = 0 */
        { 2,  2, 0, 0, 1},
        {15,  4, 0, 0, 2},
        {21,  6, 0, 0, 3},
        {23,  7, 0, 0, 4},
        {31,  8, 0, 0, 5},
        {37,  9, 0, 0, 6},
        {36,  9, 0, 0, 7},
        {33, 10, 0, 0, 8},
        {32, 10, 0, 0, 9},
        { 7, 11, 0, 0, 10},
        { 6, 11, 0, 0, 11},
        {32, 11, 0, 0, 12},
        { 6,  3, 0, 1, 1},
        {20,  6, 0, 1, 2},
        {30,  8, 0, 1, 3},
        {15, 10, 0, 1, 4},
        {33, 11, 0, 1, 5},
        {80, 12, 0, 1, 6},
        {14,  4, 0, 2, 1},
        {29,  8, 0, 2, 2},
        {14, 10, 0, 2, 3},
        {81, 12, 0, 2, 4},
        {13,  5, 0, 3, 1},
        {35,  9, 0, 3, 2},
        {13, 10, 0, 3, 3},
        {12,  5, 0, 4, 1},
        {34,  9, 0, 4, 2},
        {82, 12, 0, 4, 3},
        {11,  5, 0, 5, 1},
        {12, 10, 0, 5, 2},
        {83, 12, 0, 5, 3},
        {19,  6, 0, 6, 1},
        {11, 10, 0, 6, 2},
        {84, 12, 0, 6, 3},
        {18,  6, 0, 7, 1},
        {10, 10, 0, 7, 2},
        {17,  6, 0, 8, 1},
        { 9, 10, 0, 8, 2},
        {16,  6, 0, 9, 1},
        { 8, 10, 0, 9, 2},
        {22,  7, 0, 10, 1},
        {85, 12, 0, 10, 2},
        {21,  7, 0, 11, 1},
        {20,  7, 0, 12, 1},
        {28,  8, 0, 13, 1},
        {27,  8, 0, 14, 1},
        {33,  9, 0, 15, 1},
        {32,  9, 0, 16, 1},
        {31,  9, 0, 17, 1},
        {30,  9, 0, 18, 1},
        {29,  9, 0, 19, 1},
        {28,  9, 0, 20, 1},
        {27,  9, 0, 21, 1},
        {26,  9, 0, 22, 1},
        {34, 11, 0, 23, 1},
        {35, 11, 0, 24, 1},
        {86, 12, 0, 25, 1},
        {87, 12, 0, 26, 1},
        { 7,  4, 1, 0, 1},
        {25,  9, 1, 0, 2},
        { 5, 11, 1, 0, 3},
        {15,  6, 1, 1, 1},
        { 4, 11, 1, 1, 2},
        {14,  6, 1, 2, 1},
        {13,  6, 1, 3, 1},
        {12,  6, 1, 4, 1},
        {19,  7, 1, 5, 1},
        {18,  7, 1, 6, 1},
        {17,  7, 1, 7, 1},
        {16,  7, 1, 8, 1},
        {26,  8, 1, 9, 1},
        {25,  8, 1, 10, 1},
        {24,  8, 1, 11, 1},
        {23,  8, 1, 12, 1},
        {22,  8, 1, 13, 1},
        {21,  8, 1, 14, 1},
        {20,  8, 1, 15, 1},
        {19,  8, 1, 16, 1},
        {24,  9, 1, 17, 1},
        {23,  9, 1, 18, 1},
        {22,  9, 1, 19, 1},
        {21,  9, 1, 20, 1},
        {20,  9, 1, 21, 1},
        {19,  9, 1, 22, 1},
        {18,  9, 1, 23, 1},
        {17,  9, 1, 24, 1},
        { 7, 10, 1, 25, 1},
        { 6, 10, 1, 26, 1},
        { 5, 10, 1, 27, 1},
        { 4, 10, 1, 28, 1},
        {36, 11, 1, 29, 1},
        {37, 11, 1, 30, 1},
        {38, 11, 1, 31, 1},
        {39, 11, 1, 32, 1},
        {88, 12, 1, 33, 1},
        {89, 12, 1, 34, 1},
        {90, 12, 1, 35, 1},
        {91, 12, 1, 36, 1},
        {92, 12, 1, 37, 1},
        {93, 12, 1, 38, 1},
        {94, 12, 1, 39, 1},
        {95, 12, 1, 40, 1}
    },
    /* intra = 1 */
    {
        { 2,  2, 0, 0, 1},
        {15,  4, 0, 0, 3},
        {21,  6, 0, 0, 6},
        {23,  7, 0, 0, 9},
        {31,  8, 0, 0, 10},
        {37,  9, 0, 0, 13},
        {36,  9, 0, 0, 14},
        {33, 10, 0, 0, 17},
        {32, 10, 0, 0, 18},
        { 7, 11, 0, 0, 21},
        { 6, 11, 0, 0, 22},
        {32, 11, 0, 0, 23},
        { 6,  3, 0, 0, 2},
        {20,  6, 0, 1, 2},
        {30,  8, 0, 0, 11},
        {15, 10, 0, 0, 19},
        {33, 11, 0, 0, 24},
        {80, 12, 0, 0, 25},
        {14,  4, 0, 1, 1},
        {29,  8, 0, 0, 12},
        {14, 10, 0, 0, 20},
        {81, 12, 0, 0, 26},
        {13,  5, 0, 0, 4},
        {35,  9, 0, 0, 15},
        {13, 10, 0, 1, 7},
        {12,  5, 0, 0, 5},
        {34,  9, 0, 4, 2},
        {82, 12, 0, 0, 27},
        {11,  5, 0, 2, 1},
        {12, 10, 0, 2, 4},
        {83, 12, 0, 1, 9},
        {19,  6, 0, 0, 7},
        {11, 10, 0, 3, 4},
        {84, 12, 0, 6, 3},
        {18,  6, 0, 0, 8},
        {10, 10, 0, 4, 3},
        {17,  6, 0, 3, 1},
        { 9, 10, 0, 8, 2},
        {16,  6, 0, 4, 1},
        { 8, 10, 0, 5, 3},
        {22,  7, 0, 1, 3},
        {85, 12, 0, 1, 10},
        {21,  7, 0, 2, 2},
        {20,  7, 0, 7, 1},
        {28,  8, 0, 1, 4},
        {27,  8, 0, 3, 2},
        {33,  9, 0, 0, 16},
        {32,  9, 0, 1, 5},
        {31,  9, 0, 1, 6},
        {30,  9, 0, 2, 3},
        {29,  9, 0, 3, 3},
        {28,  9, 0, 5, 2},
        {27,  9, 0, 6, 2},
        {26,  9, 0, 7, 2},
        {34, 11, 0, 1, 8},
        {35, 11, 0, 9, 2},
        {86, 12, 0, 2, 5},
        {87, 12, 0, 7, 3},
        { 7,  4, 1, 0, 1},
        {25,  9, 0, 11, 1},
        { 5, 11, 1, 0, 6},
        {15,  6, 1, 1, 1},
        { 4, 11, 1, 0, 7},
        {14,  6, 1, 2, 1},
        {13,  6, 0, 5, 1},
        {12,  6, 1, 0, 2},
        {19,  7, 1, 5, 1},
        {18,  7, 0, 6, 1},
        {17,  7, 1, 3, 1},
        {16,  7, 1, 4, 1},
        {26,  8, 1, 9, 1},
        {25,  8, 0, 8, 1},
        {24,  8, 0, 9, 1},
        {23,  8, 0, 10, 1},
        {22,  8, 1, 0, 3},
        {21,  8, 1, 6, 1},
        {20,  8, 1, 7, 1},
        {19,  8, 1, 8, 1},
        {24,  9, 0, 12, 1},
        {23,  9, 1, 0, 4},
        {22,  9, 1, 1, 2},
        {21,  9, 1, 10, 1},
        {20,  9, 1, 11, 1},
        {19,  9, 1, 12, 1},
        {18,  9, 1, 13, 1},
        {17,  9, 1, 14, 1},
        { 7, 10, 0, 13, 1},
        { 6, 10, 1, 0, 5},
        { 5, 10, 1, 1, 3},
        { 4, 10, 1, 2, 2},
        {36, 11, 1, 3, 2},
        {37, 11, 1, 4, 2},
        {38, 11, 1, 15, 1},
        {39, 11, 1, 16, 1},
        {88, 12, 0, 14, 1},
        {89, 12, 1, 0, 8},
        {90, 12, 1, 5, 2},
        {91, 12, 1, 6, 2},
        {92, 12, 1, 17, 1},
        {93, 12, 1, 18, 1},
        {94, 12, 1, 19, 1},
        {95, 12, 1, 20, 1}
        }
    };
    static final  short SCAN_TABLES[][] = {
        /* zig_zag_scan */
        { 0,  1,  8, 16,  9,  2,  3, 10,
        17, 24, 32, 25, 18, 11,  4,  5,
        12, 19, 26, 33, 40, 48, 41, 34,
        27, 20, 13,  6,  7, 14, 21, 28,
        35, 42, 49, 56, 57, 50, 43, 36,
        29, 22, 15, 23, 30, 37, 44, 51,
        58, 59, 52, 45, 38, 31, 39, 46,
        53, 60, 61, 54, 47, 55, 62, 63},
        /* horizontal_scan */
        { 0,  1,  2,  3,  8,  9, 16, 17,
        10, 11,  4,  5,  6,  7, 15, 14,
        13, 12, 19, 18, 24, 25, 32, 33,
        26, 27, 20, 21, 22, 23, 28, 29,
        30, 31, 34, 35, 40, 41, 48, 49,
        42, 43, 36, 37, 38, 39, 44, 45,
        46, 47, 50, 51, 56, 57, 58, 59,
        52, 53, 54, 55, 60, 61, 62, 63},
        /* vertical_scan */
        { 0,  8, 16, 24,  1,  9,  2, 10,
        17, 25, 32, 40, 48, 56, 57, 49,
        41, 33, 26, 18,  3, 11,  4, 12,
        19, 27, 34, 42, 50, 58, 35, 43,
        51, 59, 20, 28,  5, 13,  6, 14,
        21, 29, 36, 44, 52, 60, 37, 45,
        53, 61, 22, 30,  7, 15, 23, 31,
        38, 46, 54, 62, 39, 47, 55, 63}
    };

    static final short[] DEFAULT_ACDC_VALUES = { 1024, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    
    static final int[][] DC_LUM_TAB = { 
        { 0, 0 }, { 4, 3 }, { 3, 3 }, { 0, 3 },
        { 2, 2 }, { 2, 2 }, { 1, 2 }, { 1, 2 }
    };
    
    static final int[][] FILTER_TAB = new int[][] {
        {14, 23, -7,  3, -1            },
        {-3, 19, 20, -6,  3, -1        },
        { 2, -6, 20, 20, -6,  3, -1    },
        {-1,  3, -6, 20, 20, -6,  3, -1}
    };
    static final int[][] SPRITE_TRAJECTORY_LEN = {
        { 0x00,   2 }, { 0x02,   3 }, { 0x03,   3 }, { 0x04,  3 },
        { 0x05,   3 }, { 0x06,   3 }, { 0x0E,   4 }, { 0x1E,  5 },
        { 0x3E,   6 }, { 0x7E,   7 }, { 0xFE,   8 }, { 0x1FE, 9 },
        { 0x3FE, 10 }, { 0x7FE, 11 }, { 0xFFE, 12 } 
    };
    
//@formatter:on
}
